﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace KonachanChanger.Extensions.P2P
{
    [DataContract]
    class Packet
    {
        public enum Methods
        {
            Initialized,
            Want,
            Have
        }
        [DataMember(Name="m")]
        public Methods Method { get; set; }
        [DataMember(Name = "d", EmitDefaultValue= false)]
        public string Data { get; set; }
        [DataMember(Name = "d2", EmitDefaultValue = false)]
        public string Data2 { get; set; }

        public static implicit operator string(Packet p)
        {
            return Kamahl.Common.Serialization.DumpToJson(p);
        }
        public static implicit operator Packet(string s)
        {
            return Kamahl.Common.Serialization.LoadFromJson<Packet>(s);
        }


    }
}
